package owg.util.editor2d.operations;

import owg.util.data.KryoInstance.K;
import owg.util.data.Pair;
import owg.util.editor2d.ConstructorParams;
import owg.util.editor2d.Editor2D;
import owg.util.editor2d.entity.Placeable2D;

public class Reviver extends Operation
{
	private Destroyer companion;
	@K private Reviver(){}
	/**Create a new reviver for the associated destroyer operation.
	 * The reference to the destroyer is needed to obtain specific information that is not available until the destruction has been executed.*/
	public Reviver(Destroyer companion)
	{
		this.companion = companion;
	}
	
	@Override
	public void apply(Editor2D w) throws OperationFailedException
	{
		for (Pair<Placeable2D,ConstructorParams> p : companion.getDestroyedObjects())
			p.a.revive();
		w.objectsRevived(companion.getDestroyedObjects(), companion.getReinsertionIndices()/*, 
			companion.getRestoreLinkData()TODO*/);
	}
}